package com.ibiaoke.boss.controller;

import com.ibiaoke.boss.entity.SysUser;
import com.ibiaoke.common.base.BaseController;
import com.ibiaoke.common.base.Page;
import com.ibiaoke.common.response.Res;
import com.ibiaoke.goods.entity.ReportLoss;
import com.ibiaoke.goods.service.ReportLossService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.Date;
import java.util.List;

@Controller
public class BossReportLossController extends BaseController {

    private Logger logger = LoggerFactory.getLogger(this.getClass().getName());

    @Autowired
    private ReportLossService reportLossService;

    @RequestMapping("/addReportLoss")
    @ResponseBody
    public Res addStock(ReportLoss reportLoss){
        SysUser user = getLoginUser();
        reportLossService.addReportLoss(user.getUserName(),reportLoss);
        logger.info("系统用户{}报损成功",user.getUserName());
        return Res.create();
    }


    @RequestMapping("/findReportLossList")
    @ResponseBody
    public Res findReportLoss(String goodName, Integer goodId, Date lossTime,Date lossEndTime,Integer shopId,Page page) {
        List<ReportLoss> reportLossList =  reportLossService.findReportLossList(goodName,goodId,lossTime,lossEndTime,shopId,page);
        return Res.create().addResponse("reportLossList", reportLossList).addResponse("page",page);
    }

}
